#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
typedef struct st
{
	int* arr;
	int size;
	int capacity;




}st;
void  SeqListInit(st* ps)
{
	ps->arr = NULL;
	ps->capacity = 0;
	ps->size = 0;
}
void CheckCapacity(st* ps)
{
	if (ps->capacity == ps->size)
	{
		int newcapacity = 0 ? 4 : ps->capacity * 2;
		int* tmp = (int*)malloc(sizeof(int) * newcapacity);
		if (tmp == NULL)
		{
			perror("malloc fail");
		}
		ps->capacity = newcapacity;
		ps->arr = tmp;
	




	}







}
void  SeqListPushBack(st* ps, int x)
{
	CheckCapacity(ps);
	ps->arr[ps->size] = x;
	ps->size++;


	

}
void  SeqListPushFront(st* ps, int x)
{
	CheckCapacity(ps);
	int end = ps->size - 1;
	while (end >= 0)
	{
		ps->arr[end + 1] = ps->arr[end];
		end--;



	}
	ps->arr[0] = x;
	ps->size++;



}
void  SeqListPrint(st* ps)
{
	for (int i = 0; i < ps->size; i++)
	{   

		printf("%d ", ps->arr[i]);



	}





}
void SeqListPopBack(st* ps)
{assert(ps->size >= 0);
ps->size--;

}
void  SeqListPopFront(st* ps)
{
	assert(ps->size >= 0);
	int begin = 1;
	while (begin<=ps->size-1)
	{

		ps->arr[begin - 1] = ps->arr[begin];
		begin++;



	}
	ps->size--;







}
void SeqListInsert(st* ps, int pos, int x)
{
	assert(pos >= 0 && pos <= ps->size);
	CheckCapacity(ps);
	int end = ps->size - 1;
	while (end >=pos)
	{
		ps->arr[end + 1] = ps->arr[end];
		end--;



	}
	ps->arr[pos] = x;
	ps->size++;







}
void SeqListErase(st* ps, int pos)
{assert(ps->size >= 0);
assert(ps->size >= 0);
int begin = pos+1;
while (begin <= ps->size - 1)
{

	ps->arr[begin - 1] = ps->arr[begin];
	begin++;



}
ps->size--;




}
void SeqListFind(st* ps, int pos)
{
	assert(pos >= 0 && pos <= ps->size - 1);
	printf("%d", ps->arr[pos]);



}
void SeqListmodify(st* ps, int x, int y)
{
	for (int i = 0; i < ps->size; i++)
	{
		if (x == ps->arr[i])
		{
			ps->arr[i] = y;
		}



	}

}
void SeqListDestory(st* ps)
{

	free(ps->arr);
	ps->arr = NULL;
	ps->capacity = 0;
	ps->size = 0;




}






int main()
{
	st list;
	SeqListInit(&list);
	SeqListPushBack(&list, 1);
	SeqListPushBack(&list, 2);
	SeqListPushBack(&list, 3);
	SeqListPushBack(&list, 4);
	
	SeqListErase(&list, 3);
	SeqListPrint(&list);
}